Crate ethers_contract

source ·
Expand description

Type-safe abstractions for interacting with Ethereum smart contracts

Interacting with a smart contract requires broadcasting carefully crafted transactions where the data field contains the function’s selector along with the arguments of the called function.

This module provides the Contract and ContractFactory abstractions so that you do not have to worry about that. It also provides typesafe bindings via the abigen macro and the Abigen builder.

Modules

Macros

abigenabigen
Proc macro to generate type-safe bindings to a contract(s). This macro accepts one or more Ethereum contract ABI or a path. Note that relative paths are rooted in the crate’s root CARGO_MANIFEST_DIR. Environment variable interpolation is supported via $ prefix, like "$CARGO_MANIFEST_DIR/contracts/c.json"

Structs

Abigenabigen
Builder struct for generating type-safe bindings from a contract’s ABI
A reduced form of Contract which just takes the abi and produces ABI encoded data for its functions.
A Contract is an abstraction of an executable program on the Ethereum Blockchain. It has code (called byte code) as well as allocated long-term memory (called storage). Every deployed Contract has an address, which is used to connect to it so that it may be sent messages to call its methods.
Helper which manages the deployment transaction of a smart contract.
To deploy a contract to the Ethereum network, a ContractFactory can be created which manages the Contract bytecode and Application Binary Interface (ABI), usually generated from the Solidity compiler.
Helper for managing the event filter before querying or streaming its logs
A Contract Filter that exclude certain contracts
Helper to match ethabi::Params with structs and nested structs
Metadata inside a log
Collects Abigen structs for a series of contracts, pending generation of the contract bindings.
Multicallabigen
A Multicall is an abstraction for sending batched calls/transactions to the Ethereum blockchain. It stores an instance of the Multicall smart contract and the user provided list of transactions to be called or executed on chain.
A Contract Filter that only includes certain contracts.

Enums

ABI codec related errors
An Error which is thrown when interacting with a smart contract
Used to filter contracts that should be included in the abigen generation.
The version of the Multicall. Used to determine which methods of the Multicall smart contract to use:

Constants

The Multicall3 contract address that is deployed in MULTICALL_SUPPORTED_CHAIN_IDS: 0xcA11bde05977b3631167028862bE2a173976CA11

Statics

Traits

A helper trait for types that represent all call input parameters of a specific function
A helper trait for types that represents a custom error type
A trait for implementing event bindings
A trait for types (events) that can be decoded from a RawLog

Functions

Helper for ABI decoding raw data based on a function’s input or output.
Decodes a series of logs into a vector
Helper for ABI encoding arguments for a specific function

Derive Macros

Derive macro for Eip712
Derives the AbiEncode, AbiDecode and traits for the labeled type.
Derives the AbiType and all Tokenizable traits for the labeled type.
EthCallabigen
Derives the EthCall and Tokenizeable trait for the labeled type.
Derives fmt::Display trait and generates a convenient format for all the underlying primitive types/tokens.
EthErrorabigen
Derives the EthError and Tokenizeable trait for the labeled type.
EthEventabigen
Derives the EthEvent and Tokenizeable trait for the labeled type.